package com.bwie.controller;

import com.bwie.pojo.User;
import com.bwie.service.AuthService;
import com.bwie.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Mikey
 * @Date: 2025/9/9 09:37
 * @Description:
 **/
@RestController
@RequestMapping("auth/index")
public class AuthController {

    @Autowired
    private AuthService authService;

    /**
     * 登录方法
     * @param user
     * @return
     */
    @PostMapping("login")
    public R login(@RequestBody @Validated User user){
        //去业务域层处理
        return authService.login(user);
    }


    /***
     * @author: 秋晚
     * @description:发送手机号获取验证码
     * @params: [com.bwie.pojo.User]
     * @return: com.bwie.utils.R
     * @date: 2025/9/9 9:52
     */
    @PostMapping("sendCode")
    public R sendCode(@RequestBody @Validated User user){
        return authService.sendCode(user);
    }
}
